<template>
	<view v-if="isLoaded">
		<li-report
			height="900"
			:param.sync="param"
			:radios.sync="radios"
			:reportData="tableData"
			:columns="columns"
			v-on:changeType="changeType($event)"
			:isShowLoadMore="isShowLoadMore"
		/>
	</view>
</template>

<script>
import date from '@/utils/date';
import LiReportMixin from '../../../mixins/liReportMixin.js';
export default {
	mixins: [LiReportMixin],
	data() {
		return {
			reportFn: 'GetPageReport',
			isShowLoadMore: true,
			param: {
				dataTimeRange: [date.getDate(0), date.getDate(0)],
				cycle: 3,
				reportId: 106,
				appointType: 1,
				pageNum: 1,
				pageSize: 20
			},
			radios: [
				{ name: '桌台', value: 1, selected: true },
				{ name: '区域', value: 2 }
			],
			columns: [
				{
					name: 'deskName',
					label: '桌台名称',
					fixed: true
				},
				{
					name: 'manQty',
					label: '标准用餐人数',
					fixed: false
				},
				{
					name: 'amount',
					label: '营业额',
					fixed: false,
					sorter: true
				},
				{
					name: 'allAmount',
					label: '营业收入',
					fixed: false,
					sorter: true
				},
				{
					name: 'reduceAmount',
					label: '优惠金额',
					fixed: false,
					sorter: true
				},
				{
					name: 'quantity',
					label: '消费桌数',
					fixed: false
				},
				{
					name: 'person',
					label: '用餐人数',
					fixed: false
				},
				{
					name: 'avgPersonAmount',
					label: '折前人均',
					fixed: false,
					sorter: true
				},
				{
					name: 'avgDiscountPersonAmount',
					label: '折后人均',
					fixed: false,
					sorter: true
				},
				{
					name: 'avgDeskAmount',
					label: '折前桌均',
					fixed: false,
					sorter: true
				},
				{
					name: 'avgDiscountDeskAmount',
					label: '折后桌均',
					fixed: false,
					sorter: true
				}
			]
		};
	},

	methods: {
		changeType(e) {
			if (this.param.appointType === 2) {
				this.columns = [
					{ name: 'deskCategoryName', label: '桌台区域', fixed: true },
					{ name: 'deckCount', label: '桌台数量', fixed: false },
					{ name: 'manQty', label: '标准用餐人数', fixed: false },
					{ name: 'amount', label: '营业额', fixed: false },
					{ name: 'allAmount', label: '营业收入', fixed: false },
					{ name: 'reduceAmount', label: '优惠金额', fixed: false },
					{ name: 'quantity', label: '消费桌数', fixed: false },
					{ name: 'person', label: '用餐人数', fixed: false },
					{ name: 'avgPersonAmount', label: '折前人均', fixed: false },
					{ name: 'avgDiscountPersonAmount', label: '折后人均', fixed: false },
					{ name: 'avgDeskAmount', label: '折前桌均', fixed: false },
					{ name: 'avgDiscountDeskAmount', label: '折后桌均', fixed: false }
				];
			} else if (this.param.appointType === 1) {
				this.columns = this.$options.data().columns;
			}
		}
	}
};
</script>
